package ink.metoo.gude.util

import java.security.MessageDigest

object MessageDigestUtils {

    fun md5(input: String): String {
        val digest = MessageDigest.getInstance("MD5")
        val result = digest.digest(input.toByteArray())
        return toHex(result)
    }

    private fun toHex(byteArray: ByteArray): String {
        return byteArray.joinToString("") {
            "%02x".format(it)
        }
    }

}
